<?php
namespace app\index\controller;

use app\common\controller\HomeBase;
use app\common\model\Suitcategory as CategoryModel;
use app\common\model\Suit as SuitModel;
use think\Session;

class SuitImg extends HomeBase
{
    protected $suit_model;

    public function _initialize(){
        parent::_initialize();
        $this->category_model = new CategoryModel();
        $this->suit_model = new SuitModel();
        $category_level_list  = $this->category_model->getLevelList();
        $erji = $this->category_model->where('pid','neq','0')->select();
        $this->assign('erjicategory_level_list', $erji);
        $this->assign('suitcategory_level_list', $category_level_list);
        $this->assign('title','套图管理共享');
    }

    public function index(){
        $result = $this->suit_model
                    ->order('id desc')
                    ->select();
        $this->assign('img_list',$result);
        return $this->fetch();
    }

    public function img_detail($id){
        $index_id = session::get('index_id');
        if($index_id){
            $list = $this->suit_model->field('id,title,path')->where('pid',$id)->select();
        }else{
            $list = $this->suit_model->field('id,title,thumb')->where('pid',$id)->limit(0,10)->select();
        }

        // dump($list);exit();
        $this->assign('list',$list);
        return $this->fetch();
    }
    public function index_bk(){
        $result = $this->suit_model
            ->order('id desc')
            ->select();
        $this->assign('img_list',$result);
        return $this->fetch();
    }

}